/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/**
 * @Title: CategoryTree.java
 * @Package phoenics.apeak.simple.entity
 * @Description
 * @author phoenics@126com
 * @date 2016-1-30 16:01:31
 * @version V1.0
 */
package phoenics.apeak.simple.entity;

import java.util.ArrayList;
import java.util.List;

import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
// TODO: Auto-generated Javadoc

/**
 * The Class CategoryTree.
 *
 * @Description The Class CategoryTree.
 */
@Document(collection="category")
public class CategoryTree {
	
	/** The id. */
	@Field("id")
	private String id;
	
	/** The name. */
	@Field("name")
	private String name;

	/** The parent id. */
	private String parentId;
	
	/** The parent. */
	@Transient 
	private CategoryTree parent=null;
	
	/** The children. */
	@Transient 
	private List<CategoryTree> children=new ArrayList<>();
	

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "AllTree [id=" + id + ", name=" + name + ", pid=" +parentId + "]";
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		CategoryTree at = (CategoryTree) obj;
		if (this.getId().equals(at.id) ) {
			return true;
		}
		return false;
	}

	/**
 * The Constructor.
 *
 * @Description Instantiates a new category tree.
 */
	public CategoryTree() {
	}

	/**
 * The Constructor.
 *
 * @param id
 *            the id
 * @param name
 *            the name
 * @param pid
 *            the pid
 * @Description Instantiates a new category tree.
 */
	public CategoryTree(String id, String name, String pid) {
		super();
		this.id = id;
		this.name = name;
		this.parentId = pid;
	}

	/**
 * Gets the id.
 *
 * @return the id
 */
	public String getId() {
		return id;
	}

	/**
 * Sets the id.
 *
 * @param id
 *            the new id
 */
	public void setId(String id) {
		this.id = id;
	}

	/**
 * Gets the name.
 *
 * @return the name
 */
	public String getName() {
		return name;
	}

	/**
 * Sets the name.
 *
 * @param name
 *            the new name
 */
	public void setName(String name) {
		this.name = name;
	}

	/**
 * Gets the parent id.
 *
 * @return the parent id
 */
	public String getParentId() {
		return parentId;
	}

	/**
 * Sets the parent id.
 *
 * @param pid
 *            the new parent id
 */
	public void setParentId(String pid) {
		this.parentId = pid;
	}

	/**
 * Gets the children.
 *
 * @return the children
 */
	public List<CategoryTree> getChildren() {
		return children;
	}


	/**
 * Gets the parent.
 *
 * @return the parent
 */
	public CategoryTree getParent() {
		return parent;
	}

	/**
 * Sets the parent.
 *
 * @param parent
 *            the new parent
 */
	public void setParent(CategoryTree parent) {
		this.parent = parent;
	}



	

}
